﻿using Microsoft.AspNetCore.Mvc;
using WMS.FC.Application.Technology.Interface;
using WMS.FC.Domain.DataTransferObject.System;
using WMS.FC.Domain.DataTransferObject.Technology;
using WMS.FC.Domain.DomainObject.System;
using WMS.FC.Infrastructure.Filter;

namespace WMS.FC.WebApi.Controllers
{
    /// <summary>
    /// 工艺控制器
    /// </summary>
    public class TechnologyController : BaseConroller
    {
        /// <summary>
        /// 工艺服务
        /// </summary>
        protected readonly ITechnologyService technologyService;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="technologyService"></param>
        public TechnologyController(ITechnologyService technologyService)
        {
            this.technologyService = technologyService;
        }

        /// <summary>
        /// 新增工艺路径
        /// </summary>
        /// <param name="dTO"></param>
        /// <returns></returns>
        [HttpPost]
        [TypeFilter(typeof(WMSFilter))]
        public async Task<IActionResult> AddTechnologyRoute(AddDataDTO<EditTechnologyRouteDTO> dTO)
        {
            var response = await technologyService.AddTechnologyRoute(dTO);
            return Ok(response);
        }

        /// <summary>
        /// 新增工艺路径工序
        /// </summary>
        /// <param name="dTO"></param>
        /// <returns></returns>
        [HttpPost]
        [TypeFilter(typeof(WMSFilter))]
        public async Task<IActionResult> AddTechnologyRouteProcess(AddDataDTO<EditTechnologyRouteProcessDTO> dTO)
        {
            var response = await technologyService.AddTechnologyRouteProcess(dTO);
            return Ok(response);
        }

        /// <summary>
        /// 删除工艺路径
        /// </summary>
        /// <param name="dTO"></param>
        /// <returns></returns>
        [HttpPost]
        [TypeFilter(typeof(WMSFilter))]
        public async Task<IActionResult> DeleteTechnologyRoute(HandleButtonDTO dTO)
        {
            var response = await technologyService.DeleteTechnologyRoute(dTO);
            return Ok(response);
        }

        /// <summary>
        /// 删除工艺路径工序
        /// </summary>
        /// <param name="dTO"></param>
        /// <returns></returns>
        [HttpPost]
        [TypeFilter(typeof(WMSFilter))]
        public async Task<IActionResult> DeleteTechnologyRouteProcess(HandleButtonDTO dTO)
        {
            var response = await technologyService.DeleteTechnologyRouteProcess(dTO);
            return Ok(response);
        }

        /// <summary>
        /// 编辑工艺路径
        /// </summary>
        /// <param name="dTO"></param>
        /// <returns></returns>
        [HttpPost]
        [TypeFilter(typeof(WMSFilter))]
        public async Task<IActionResult> EditTechnologyRoute(EditDataDTO<EditTechnologyRouteDTO> dTO)
        {
            var response = await technologyService.EditTechnologyRoute(dTO);
            return Ok(response);
        }

        /// <summary>
        /// 编辑工艺路径工序
        /// </summary>
        /// <param name="dTO"></param>
        /// <returns></returns>
        [HttpPost]
        [TypeFilter(typeof(WMSFilter))]
        public async Task<IActionResult> EditTechnologyRouteProcess(EditDataDTO<EditTechnologyRouteProcessDTO> dTO)
        {
            var response = await technologyService.EditTechnologyRouteProcess(dTO);
            return Ok(response);
        }

        /// <summary>
        /// 获取工艺路径列表
        /// </summary>
        /// <param name="dTO"></param>
        /// <returns></returns>
        [HttpPost]
        [TypeFilter(typeof(WMSFilter))]
        public async Task<IActionResult> GetTechnologyRouteList(RequestBase dTO)
        {
            var response = await technologyService.GetTechnologyRouteList(dTO);
            return Ok(response);
        }

        /// <summary>
        /// 获取工艺路径工序列表
        /// </summary>
        /// <param name="dTO"></param>
        /// <returns></returns>
        [HttpPost]
        [TypeFilter(typeof(WMSFilter))]
        public async Task<IActionResult> GetTechnologyRouteProcessList(GetTechnologyRouteProcessListDTO dTO)
        {
            var response = await technologyService.GetTechnologyRouteProcessList(dTO);
            return Ok(response);
        }
    }
}
